package com.itheima.consumer.feign;

import com.itheima.consumer.config.FeignLogConfig;
import com.itheima.consumer.domain.Goods;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/*
         String url = "http://FEIGN-PROVIDER/goods/findOne/"+id;
        // 3. 调用方法
        Goods goods = restTemplate.getForObject(url, Goods.class);

        feign声明式接口.发起远程调用的
        1.定义接口
        2.接口上添加@FeignClient(),设置属性value=("服务提供者的应用名称")
        3.编写调用接口,接口的声明规则和提供方接口保持一致(参数和请求参数保持一致)
        4.注入该接口对象,调用接口方法完成远程调用
 */

@FeignClient(value = "feign-provider", configuration = FeignLogConfig.class)
public interface GoodsFeignClient {

    @GetMapping("/goods/findOne/{id}")
    public Goods findGoodsById(@PathVariable("id") int id);
}
